import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';

import 'flutter_restart_app_platform_interface.dart';

/// An implementation of [FlutterRestartAppPlatform] that uses method channels.
class MethodChannelFlutterRestartApp extends FlutterRestartAppPlatform {
  /// 用于与原生平台交互的 method channel
  @visibleForTesting
  final methodChannel = const MethodChannel('flutter_restart_app');

  @override
  Future<String?> getPlatformVersion() async {
    final version =
        await methodChannel.invokeMethod<String>('getPlatformVersion');
    return version;
  }

  /// 重新启动应用程序
  @override
  Future<bool> restartApp() async {
    return await methodChannel.invokeMethod('restart');
  }
}
